package talkplace;

import java.awt.EventQueue;
import java.awt.Frame;

import javax.swing.JFrame;

import org.eclipse.swt.SWT;

import java.awt.Button;
import java.awt.Color;
import java.awt.List;
import java.awt.TextArea;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import talkplace.client;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class login  extends client{

	private JFrame frame;
    private client client;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					login window = new login();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	
	}

	/**
	 * Create the application.
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	public login() throws UnknownHostException, IOException {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	private void initialize() throws UnknownHostException, IOException {
		frame = new JFrame();
		client=new client();
	
		frame.setBounds(100, 100, 776, 601);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
			Button button = new Button("New button");
				button.setForeground(Color.DARK_GRAY);
		button.setBounds(411, 518, 88, 36);
		frame.getContentPane().add(button);
		
		List list = new List();
		list.setBounds(578, 112, 174, 442);
		frame.getContentPane().add(list);
	
		TextArea showArea = new TextArea();
		showArea.setBounds(10, 59, 489, 327);
		frame.getContentPane().add(showArea);
		
		TextArea inputArea = new TextArea();
		inputArea.setText("123");
		inputArea.setBounds(10, 394, 489, 160);
		frame.getContentPane().add(inputArea);
		
		
	

	  try {
		  
		client.getList(list);
		client.getshowArea(showArea);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}	
	 button.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent e) {
					try {
					client.putitem(inputArea);
					} catch (IOException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				}
			});
	}
}
